<template>
  <div>
    <div class="top" :style="backgroundColor">
      <div class="topl">
        <span class="iconfont icon-right-arrow" @click="backClick"></span>
      </div>
      <div class="topr">
        <span class="iconfont icon-fenxiang"></span>
        <span class="iconfont icon-sangedian"></span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      backgroundColor: " background-color:rgba(36, 38, 44,0.6)",
    };
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  },
  methods: {
    backClick() {
      console.log("backClick");
      this.$router.go(-1);
    },
    handleScroll() {
      let scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      if (scrollTop >= 50) {
        this.backgroundColor = "background-color:rgba(36, 38, 44,0.96)";
      }  else {
        this.backgroundColor = "background-color:rgba(36, 38, 44,0.6)";
      }
    }
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.handleScroll);
  }
};
</script>
<style scoped>
@import url(../../assets/font/iconfont);
.top {
  display: flex;
  padding: 5px;
  font-size: 20px;
  color: #fff;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}
.top span {
  display: block;
  width: 25px;
  height: 25px;
  line-height: 25px;
  text-align: center;
  border-radius: 50%;
  background-color: black;
}
.topr {
  display: flex;
}
.topr span {
  margin-left: 16px;
}
</style>